import {createStore,applyMiddleware} from "redux"
import logger from "redux-logger"
import reducer from "./reducer"
import thunk from "redux-thunk"
import { persistStore,persistReducer } from 'redux-persist'
import storage from "redux-persist/lib/storage"
//对 reducer 进行 持久化处理
const persistedReducer = persistReducer({key: 'root',storage}, reducer)

//创建一个唯一的store
//applyMiddleware() 应用中间件(插件)
let store = createStore( persistedReducer, applyMiddleware(thunk, logger) )

//对唯一的store进行持久化处理
let persistor = persistStore(store);

export {
    store,
    persistor
} 